$("#addContactBtn").on("click", function () {
    var stayWordName = $(".stayWordName").val();
    var stayWordEmail = $(".stayWordEmail").val();
    var stayWordTitle = $(".stayWordTitle").val();
    var stayWordContent = $(".stayWordContent").val();
    var reg_userEmail = /^\w+@\w+(\.[a-zA-Z]{2,3}){1,2}$/;
    if (stayWordName != null && stayWordName.length != 0
        && stayWordTitle != null && stayWordTitle.length != 0
        && stayWordContent != null && stayWordContent.length != 0) {
        if (stayWordEmail != null && stayWordEmail.length != 0 && reg_userEmail.test(stayWordEmail)) {
            $.ajax({
                type: "POST",
                url: "/addStayWord",
                data: {
                    stayWordName: stayWordName,
                    stayWordEmail: stayWordEmail,
                    stayWordTitle: stayWordTitle,
                    stayWordContent: stayWordContent
                },
                dataType: "json",
                success: function (data) {
                    if (data.result == "success") {
                        alert("留言成功，我会尽快回复您，谢谢");
                        window.location.reload();
                    }
                },
                error: function () {
                    alert("留言失败");
                }
            });
        } else {
            alert("邮箱格式错误");
        }
    } else {
        alert("请输入所有留言信息");
    }
});